#include <bits/stdc++.h>

using namespace std;

/**
* @param n: a decimal number
* @param k: a Integer represent base-k
* @return: a base-k number
*/
string hexConversion(int n, int k)
{
    // write your code here
    char hex[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    string num = "";
    int remainder;
    while(n >= k){
        remainder = n % k;
        num = hex[remainder] + num;
        n /= k;
    }
    remainder = n % k;
    num = hex[remainder] + num;
    return num;
}

int main()
{
    cout << hexConversion(5, 2) << endl;
    cout << hexConversion(30, 16) << endl;
    return 0;
}

/**
进制转换：
Given a decimal number n and an integer k, Convert decimal number n to base-k.
注意事项

1.0<=n<=2^31-1, 2<=k<=16
2.Each letter over 9 is indicated in uppercase
样例

Example 1:
Given n = 5, k = 2
return "101"

Example 2:
Given n = 30, k = 16
return "1E"
*/
